package cz.mff.cuni.dpp.liboptions;

import java.text.MessageFormat;

/**
 * Výjimka, je vyhozena v případě, kdy se uživatel pokusí volbě přidat
 * alias (synonymum), který už je jednou přiřazen.
 */
@SuppressWarnings("serial")
public class OptionAliasConflictException extends RuntimeException {

	private static final String MESSAGE = "You are trying to add option {0} when there is allready oiption {1}, conflict on alias {2}";

	private final Option<?> allreadyThereOption;
	private final Option<?> newOption;
	private final String conflictingAlias;

	public OptionAliasConflictException(Option<?> allreadyThereOption, Option<?> newOption,
			String conflictingAlias) {
		super(MessageFormat.format(MESSAGE, newOption.getPrimaryName(),
				allreadyThereOption.getPrimaryName(), conflictingAlias));

		this.allreadyThereOption = allreadyThereOption;
		this.newOption = newOption;
		this.conflictingAlias = conflictingAlias;
	}

	Option<?> getAllreadyThereOption() {
		return allreadyThereOption;
	}

	Option<?> getNewOption() {
		return newOption;
	}

	String getConflictingAlias() {
		return conflictingAlias;
	}

}
